#ifndef __GROW_H__
#define __GROW_H__

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/* #include <malloc.h> */
#include <string.h>
#include <sys/types.h>
#ifndef __COMPLEX_H__
#define __COMPLEX_H__
#include <complex.h>
#endif

/* ------------------------ Type Definitions ------------------------ */

typedef struct GROW_PNMIMAGE 
{
  unsigned char **rawImage;
  int nrows, ncols;
  char name[72];
} GROW_IMG, *GROW_IMGPTR;

/* TODO: move this to the API */
typedef enum eGrowDisplayType{
  GROW_NO_DISPLAY,
  GROW_DISPLAY_END,
  GROW_DISPLAY_GROW_ANIMATION
}GROWDISPLAYTYPE;

/* ------------------------ Private Attributes ------------------------ */
unsigned int loopCountX;               // counter for the x direction
unsigned int loopCountY;               // counter for the y direction
unsigned int totalGrowRecursiveCall;   // keeps track of total recursive calls
unsigned int maxRecursiveCallStack;    // maintains max stack count for recurs call
unsigned int labelCounter;             // label counter to control label names
unsigned int printAnimation;
unsigned char buf[64];                 // buffer for line read from file 
GROW_IMG growImage;                    // raw image data

/* ------------------------ Function Mappings ------------------------ */

#define p_initGrow                  i_initGrow
#define p_printGrowMatrix           i_printGrowMatrix
#define p_startAutoGrow             i_startAutoGrow
#define p_deallocGrow               i_deallocGrow

/* ------------------------ Inlined Methods ------------------------ */

#define p_getTotalRecursiveCalls()  totalGrowRecursiveCall
#define p_growGetNumberOfPixels()      (growImage.nrows * growImage.ncols)

/* ------------------------ Public Methods ------------------------ */
void i_initGrow(char * growFileName);
void i_printGrowMatrix(void);
void i_startAutoGrow(GROWDISPLAYTYPE growDisplayType);
void i_deallocGrow(void);

/* ------------------------ Private Methods ------------------------ */

void grow(int CoordX, int CoordY, int label);
unsigned char **growAllocateMatrix(int length, int height);


#endif __GROW_H__
